The handed out homework:
Homework2.shallowater.doc

Guide to math parts of solutions:
MPO663.Homework2.solutions.pdf

Matlab code for plotting solutions
Homework2_figs.m


Take off the lid at the tropopause:


Recall that the boundary condition w=0 at z=0 meant that W and T must be only sines in z (no cosine component),
which means that U and Φ are cosines only (related to W and T by mass continuity and hydrostatic balance, respectively).

But it was the UPPER lid boundary condition w=0 at z=14km that made the vertical modes
discrete (1 cycle/14km, 2 cycles/14km, ...infinity). This discreteness is artificial: without an
upper lid there is a continuous set of modes.

Our computer solution is based on adding up modes, so we need a discrete spectrum to sum up.
But we could at least move the lid to a higher altitude, say 28km. Then the discrete modes are
(1 cycle/28km, 2 cycles/28km, 3, 4, ...infinity). Twice as many modes are permitted.

How the heating profile excites the modes of a 28km layer

Suppose the heating applies only in the troposphere:
28km_lid_case.Qprofiles.gif
How does it project on the modes of the whole 28km layer?

28km_lid_case.modes.gif

By eye you can see that all 3 heating profiles project positively on the deepest mode w profile
(left, all positive) so all our heatings would drive deeeep upward motions like this. They all project
even better on the next mode (both the mode and the forcing are positive throughout the troposphere).
Also the 3rd mode is mostly ascent through the troposphere, so all our heatings will excite that.
Beyond that, the top vs. bottom heaviness pf q(z) within the troposphere will start to matter.

Formally, we just want the Fourier transform of our heating profiles (imaginary part = sine waves).
Let's do it an old fashioned way: build the projection by hand. Key line of code:

print, total( qdeep * sin(0.5*zrad *imode) )


Results:
Deep convective heating projection on mode 1
5.92306
Deep convective heating projection on mode 2
7.00000
Deep convective heating projection on mode 3
3.58389
Deep convective heating projection on mode 4
2.83122e-07
Deep convective heating projection on mode 5
-0.867841
Deep convective heating projection on mode 6
1.31130e-06
Deep convective heating projection on mode 7
0.415428
...Notice the projection on even numbered modes (except for 2) are all tiny.


Now the second mode (vertical dipole within troposphere, positive lobe nearest ground):

print, total( qmode2 * sin(0.5*zrad *imode) ) (loop)

Results:
S dipole heating projection on mode 1
-2.33916
S dipole heating projection on mode 2
2.83122e-07
S dipole heating projection on mode 3
5.05522
S dipole heating projection on mode 4 BIGGEST PROJECTION, SEE WHY?
7.00000
S dipole heating projection on mode 5
3.99932
S dipole heating projection on mode 6
-1.87755e-06
S dipole heating projection on mode 7
-1.11905


Now for the top-heavy case:it's just linear so we could add the above. In fact, here's a table.
You just need to sum over these modes to get a solution with the lid at 28km instead of 14km.
(It looks like we could truncate at say 9 or 7 and get most of it).

Deep (convective only) heating projection on modes
1 5.92
2 7.00
3 3.58
4 0.00
5 -0.868
6 0.00
7 0.415
8 0.00
9 -0.251
10 0.00
11 0.173
12 0.00
13 -0.129
14 0.00
15 0.102
Top heavy (convective + stratiform type) heating projection on modes
1 7.09
2 7.00
3 1.06
4 -3.50
5 -2.87
6 0.00
7 0.975
8 -0.00
9 -0.545
10 0.00
11 0.363
12 0.00
13 -0.266
14 -0.00
15 0.209
...






[[code format="idl"]]
code (IDL)

graph 1 of heating profiles:
z = findgen(29)
zrad = z* !pi/14.
qdeep = (sin(zrad))*(z le 14)
qmode2 = (sin(2*zrad))*(z le 14)
plot, qdeep, z, xra=[0,1.5], tit='heating profiles in 28km layer', ytit='z (km)'
oplot, qdeep-0.5*qmode2, z, color=250
oplot, qdeep+0.5*qmode2, z, color=50

graph 2 of sine modes:
plot, sin(0.5*zrad), z, xra=[-1,9],tit='modes satisfying w=0 boundary conditions'
oplot, sin(0.5*zrad*2) +2, z
oplot, sin(0.5*zrad*3) +4, z
oplot, sin(0.5*zrad*4) +6, z
oplot, sin(0.5*zrad*5) +8, z

the "slow fourier transform" (manual projection):
.run
for imode = 1,15 do begin
print, 'Deep convective heating projection on mode ', imode
print, total( qdeep * sin(0.5*zrad *imode) )/29 ;;; just integrate (or average) their product - amplitude arbitrary so simple sum
endfor
for imode = 1,15 do begin
print, 'Deep convective heating projection on mode ', imode
print, total( qmode2 * sin(0.5*zrad *imode) ) ;;; just integrate (or average) their product - amplitude arbitrary so simple sum
endfor

print, 'Deep (convective only) heating projection on modes '
for imode = 1,15 do begin
proj = total( (qdeep) * sin(0.5*zrad *imode) )
print, imode, ' ', round_any(proj, sig=3)
endfor

print, 'Top heavy (convective + stratiform type) heating projection on modes '
for imode = 1,15 do begin
proj = total( (qdeep - qmode2/2) * sin(0.5*zrad *imode) )
print, imode, ' ', round_any(proj, sig=3)
endfor

end